<template>
	<view class="page-container">
		<!-- 会员信息区域 -->
		<view class="member-header">
			<view class="member-info">
				<view class="level-info">
					<text class="level-text">当前等级</text>
					<text class="level-value">{{ userInfo.level || '普通会员' }}</text>
				</view>
				<view class="exp-info">
					<text class="exp-text">距离下一等级还需</text>
					<text class="exp-value">{{ userInfo.nextLevelExp || 1000 }}经验</text>
				</view>
			</view>
			<view class="exp-bar">
				<view class="exp-progress" :style="{ width: (userInfo.currentExp / userInfo.nextLevelExp * 100) + '%' }"></view>
			</view>
		</view>
		
		<!-- 会员特权区域 -->
		<view class="privileges-section">
			<view class="section-title">
				<text class="title-text">会员特权</text>
				<text class="title-desc">尊享更多专属权益</text>
			</view>
			<view class="privileges-grid">
				<view class="privilege-item" v-for="(item, index) in privileges" :key="index">
					<view class="privilege-icon" :style="{ background: item.bgColor }">
						<text class="icon">{{ item.icon }}</text>
					</view>
					<text class="privilege-name">{{ item.name }}</text>
					<text class="privilege-desc">{{ item.description }}</text>
				</view>
			</view>
		</view>
		
		<!-- 会员套餐区域 -->
		<view class="packages-section">
			<view class="section-title">
				<text class="title-text">会员套餐</text>
				<text class="title-desc">选择最适合您的方案</text>
			</view>
			<view class="packages-list">
				<view class="package-item" v-for="(item, index) in packages" :key="index" @click="selectPackage(item)">
					<view class="package-header">
						<text class="package-name">{{ item.name }}</text>
						<text class="package-price">¥{{ item.price }}</text>
					</view>
					<view class="package-content">
						<text class="package-duration">{{ item.duration }}</text>
						<text class="package-save" v-if="item.save">省{{ item.save }}元</text>
					</view>
					<view class="package-tag" v-if="item.tag">{{ item.tag }}</view>
				</view>
			</view>
		</view>
		
		<!-- 会员专享活动 -->
		<view class="events-section">
			<view class="section-title">
				<text class="title-text">会员专享</text>
				<text class="title-desc">尊享会员专属活动</text>
			</view>
			<view class="events-list">
				<view class="event-item" v-for="(item, index) in events" :key="index" @click="viewEvent(item)">
					<image class="event-image" :src="item.image" mode="aspectFill"></image>
					<view class="event-info">
						<text class="event-title">{{ item.title }}</text>
						<text class="event-time">{{ item.time }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {
					level: '普通会员',
					currentExp: 500,
					nextLevelExp: 1000
				},
				privileges: [
					{
						name: '智能匹配',
						description: '优先匹配心仪对象',
						icon: '❤️',
						bgColor: '#FF69B4'
					},
					{
						name: '无限聊天',
						description: '畅聊无限制',
						icon: '💬',
						bgColor: '#4CAF50'
					},
					{
						name: '专属活动',
						description: '会员专享线下活动',
						icon: '🎉',
						bgColor: '#FF6B6B'
					},
					{
						name: '优先推荐',
						description: '个人资料优先展示',
						icon: '⭐',
						bgColor: '#FFD700'
					},
					{
						name: '专属客服',
						description: '24小时专属服务',
						icon: '��‍💼',
						bgColor: '#9C27B0'
					},
					{
						name: '隐私保护',
						description: '高级隐私设置',
						icon: '🔒',
						bgColor: '#2196F3'
					}
				],
				packages: [
					{
						name: '月度会员',
						price: 29.9,
						duration: '30天',
						save: '10'
					},
					{
						name: '季度会员',
						price: 79.9,
						duration: '90天',
						save: '30',
						tag: '最受欢迎'
					},
					{
						name: '年度会员',
						price: 299.9,
						duration: '365天',
						save: '150'
					}
				],
				events: [
					{
						title: '会员专属派对',
						time: '本周六 19:00',
						image: '/static/images/event1.jpg'
					},
					{
						title: '高端相亲会',
						time: '下周三 14:00',
						image: '/static/images/event2.jpg'
					}
				]
			}
		},
		methods: {
			selectPackage(pkg) {
				// TODO: 处理套餐选择
				uni.showToast({
					title: '选择套餐：' + pkg.name,
					icon: 'none'
				})
			},
			
			viewEvent(event) {
				uni.navigateTo({
					url: `/pages/event/detail?id=${event.id}`
				})
			}
		}
	}
</script>

<style lang="scss">
.page-container {
	min-height: 100vh;
	background: #f8f9fa;
	padding-bottom: 30rpx;
	
	.member-header {
		background: linear-gradient(135deg, #f69489, #ff6b6b);
		padding: 30rpx;
		color: #fff;
		border-radius: 0 0 30rpx 30rpx;
		box-shadow: 0 4rpx 20rpx rgba(246, 148, 137, 0.3);
		
		.member-info {
			display: flex;
			justify-content: space-between;
			margin-bottom: 20rpx;
			
			.level-info, .exp-info {
				text-align: center;
				
				.level-text, .exp-text {
					font-size: 24rpx;
					opacity: 0.8;
					display: block;
					margin-bottom: 8rpx;
				}
				
				.level-value, .exp-value {
					font-size: 36rpx;
					font-weight: 600;
					display: block;
				}
			}
		}
		
		.exp-bar {
			height: 8rpx;
			background: rgba(255, 255, 255, 0.2);
			border-radius: 4rpx;
			overflow: hidden;
			
			.exp-progress {
				height: 100%;
				background: #fff;
				border-radius: 4rpx;
				transition: width 0.3s ease;
			}
		}
	}
	
	.section-title {
		padding: 30rpx;
		padding-bottom: 20rpx;
		
		.title-text {
			font-size: 32rpx;
			font-weight: 600;
			color: #333;
			display: block;
			margin-bottom: 8rpx;
		}
		
		.title-desc {
			font-size: 24rpx;
			color: #999;
		}
	}
	
	.privileges-section {
		.privileges-grid {
			display: grid;
			grid-template-columns: repeat(2, 1fr);
			gap: 20rpx;
			padding: 0 20rpx;
			
			.privilege-item {
				background: #fff;
				border-radius: 16rpx;
				padding: 20rpx;
				box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
				
				.privilege-icon {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-bottom: 16rpx;
					
					.icon {
						font-size: 40rpx;
					}
				}
				
				.privilege-name {
					font-size: 28rpx;
					font-weight: 500;
					color: #333;
					display: block;
					margin-bottom: 8rpx;
				}
				
				.privilege-desc {
					font-size: 24rpx;
					color: #999;
					display: block;
				}
			}
		}
	}
	
	.packages-section {
		.packages-list {
			padding: 0 20rpx;
			
			.package-item {
				background: #fff;
				border-radius: 16rpx;
				padding: 20rpx;
				margin-bottom: 20rpx;
				box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
				position: relative;
				
				.package-header {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 12rpx;
					
					.package-name {
						font-size: 32rpx;
						font-weight: 600;
						color: #333;
					}
					
					.package-price {
						font-size: 36rpx;
						font-weight: 600;
						color: #f69489;
					}
				}
				
				.package-content {
					display: flex;
					align-items: center;
					
					.package-duration {
						font-size: 24rpx;
						color: #666;
						margin-right: 16rpx;
					}
					
					.package-save {
						font-size: 24rpx;
						color: #ff6b6b;
						background: rgba(255, 107, 107, 0.1);
						padding: 4rpx 12rpx;
						border-radius: 20rpx;
					}
				}
				
				.package-tag {
					position: absolute;
					top: -10rpx;
					right: 20rpx;
					background: #ff6b6b;
					color: #fff;
					font-size: 20rpx;
					padding: 4rpx 12rpx;
					border-radius: 20rpx;
				}
			}
		}
	}
	
	.events-section {
		.events-list {
			padding: 0 20rpx;
			
			.event-item {
				background: #fff;
				border-radius: 16rpx;
				overflow: hidden;
				margin-bottom: 20rpx;
				box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
				
				.event-image {
					width: 100%;
					height: 300rpx;
				}
				
				.event-info {
					padding: 16rpx;
					
					.event-title {
						font-size: 28rpx;
						font-weight: 500;
						color: #333;
						display: block;
						margin-bottom: 8rpx;
					}
					
					.event-time {
						font-size: 24rpx;
						color: #999;
					}
				}
			}
		}
	}
}
</style>
